﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using Utils;

namespace PolarSonicLink
{
    public class Config
    {
        public Config()
        {

        }

        public static Config GetConfig()
        {
            if ( m_config == null )
            {
                try
                {
                    XmlSerializer xs = new XmlSerializer(typeof(Config));
                    FileInfo file = ApplicationData.User.GetFile("Config.xml");
                    FileStream fs = new FileStream(file.FullName , FileMode.Open, FileAccess.Read);

                    object cfgObj = xs.Deserialize(fs);

                    if ( cfgObj is Config )
                    {
                        m_config = cfgObj as Config;
                    }

                    fs.Close();
                }
                catch ( Exception exception )
                {
                    MessageBox.Show(exception.Message);

                    m_config = new Config();
                }
            }

            return m_config;
        }

        [XmlElement("GraphResolution")]
        public int GraphResolution
        {
            get; 
			set;
        }

        private static Config m_config = null;
    }
}
